<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>在线点餐系统管理平台</title>

<link rel="stylesheet" href="${pageContext.request.contextPath }/admin/css/orderlist.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${pageContext.request.contextPath }/admin/css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${pageContext.request.contextPath }/admin/css/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${pageContext.request.contextPath }/admin/css/invalid.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${pageContext.request.contextPath }/admin/css/jquery_dialog.css" type="text/css" media="screen" />
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/simpla.jquery.configuration.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/facebox.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/jquery.wysiwyg.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/jquery.datePicker.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/jquery.date.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/jquery_dialog.js"></script> 
<script type="text/javascript">

	function goPage(toPage){
		var frm = document.getElementById("frmPage");
		frm["pageObj.currPage"].value=toPage;
		frm.submit();
	}
	//显示详情
	function showdetial(id,deskNo,peploNo,totalPrice,createTime,state){
		
		var _state=(state=='2')?"已付款":(state=='1')?"未付款":"已过期";
		var content="<div class='divtitle'>订单详情</div>";
		content+="<table class='orderditial'>";
		content+="<tr><td colspan=''>订单编号："+id+" </td><td colspan=''>订单状态："+_state+" </td></tr>";
		content+="<tr><td colspan=''>价格总计："+totalPrice+" </td><td colspan=''>下单时间："+createTime+" </td></tr>";
		content+="</table>";
		content+="<div class='divtitle'>餐桌详情</div>";
		content+="<table class='orderditial'>";
		content+="<tr><td>餐桌编号："+deskNo+" </td><td>就餐人数："+peploNo+" </td></tr>";
		content+="</table>";
		content+="<div class='divtitle1'>菜单</div>";
		content+="<table class='fooddetial'>";
		content+="<tr><th>菜名</th><th>类别</th><th>单价</th><th>数量</th><th>小计</th></tr>";
		content+="<tbody id='fooddetialinfo'></tbody>";
		content+="</table>";
		new Dialog(content,{
						"width":"550px",
						"title":'订单详情',
						'modal':true,
						"closeModal":false
					});
		var url="ordermanager!orderTetial";
		$.post(url,{"orderInfoid":id},function(data){
			if(data==""){
				$("#fooddetialinfo").html("<td colspan='5'>五菜单信息</td>");
			}
			else{
				var ListObj=eval(data);
				var tdObj="";
				var totalprice=0;
				for(var i=0;i<ListObj.length;i++){
					var foodObj=ListObj[i];
					totalprice+=parseFloat(foodObj.totleprice);
					tdObj+="<tr><td>"+foodObj.name+"</td><td>"+foodObj.type+"</td><td>"+foodObj.price+"</td><td>"+foodObj.count+"</td><td>"+foodObj.totleprice+"</td></tr>";
				}
				tdObj+="<tr><td colspan='6' style='background-color:#C5CBD7;'>总计："+totalprice+"</td></tr>";
				$("#fooddetialinfo").html(tdObj);
			}
			
		});
	};

</script>
</head>
  <body>
  <%-- 加载左边菜单 --%>
  <s:include value="../main/left.jsp?mid=m11"></s:include>
  
  <div class="clear"></div>
  <div id="main-content">
  
   <!-- Box Content -->
   <div class="content-box">
   
    <!-- Box Header -->
		<div class="content-box-header">
	    <h3>全部订单列表</h3>
	    <div class="clear"></div>
	    	
  	</div>
  	<!-- End Box header -->
    
  	<!-- Table Content -->
  	<div class="tab-content">
  		<table>
  			<thead>
  				<tr>
  			<!--  <th><input class="check-all" type="checkbox" /></th>-->
  			<th>订单编号</th>
            <th>餐桌号</th>
            <th>就餐人数</th>
            <th>合计</th>
            <th>下单时间</th>
            <th>状态</th>
            <th>操作</th>
          </tr>
        </thead>
        <tfoot>
          <tr>
            <td colspan="6">
              
              <div class="pagination">
              <s:form action="ordermanager!list" namespace="/admin" id="frmPage">
              <s:textfield name="pageObj.currPage" size="1"/>/${pageObj.allPages }页，每页显示${pageObj.rows }行，共${pageObj.allRows }行
							<input type="submit" value="GO!"/>
								<input type="hidden" name="state" value="0"/>
								<input type="hidden" name="gopage" value="alllist"/>
							<a href="javascript:goPage('1')">&laquo; 首页</a>
							<s:if test="pageObj.hasPrePage">
							<a href="javascript:goPage('${pageObj.prePage }')">&laquo; 上一页</a>
							</s:if>
							<s:if test="pageObj.hasNextPage">
							<a href="javascript:goPage('${pageObj.nextPage }')">下一页 &raquo;</a>
							</s:if>
							<a href="javascript:goPage('${pageObj.allPages }')">尾页 &raquo;</a>
							</s:form>
              </div>
              <!-- End .pagination -->
              <div class="clear"></div>
            </td>
          </tr>
        </tfoot>
        <tbody>
        <s:iterator value="pageObj.results" var="temp">
	  		<tr>
	  		 <!--  <td><input type="checkbox" name="foodId" value="${temp.id }" /></td>-->
	  		  <td>${temp.id}</td>
  			  <td>${temp.deskNo }</td>
  			  <td>${temp.peploNo }</td>
  			  <td>${temp.totalPrice }</td>
  			  <td>${temp.createTime }</td>
  			  <td >
					<s:if test="#temp.state==2">
	  			  	<lable style="color:blue" align="center">已付款</lable>
	  			  	</s:if>
	  			  	<s:elseif test="#temp.state==1">
	  			  	<lable style="color:green">未付款</lable>
	  			  	</s:elseif>
	  			  	<s:else>
	  			  	<lable style="color:gray">已过期</lable>
	  			  	</s:else>
				</td>
  			  <td>
						<a href="#" title="详细信息" onclick="showdetial('${temp.id}','${temp.deskNo }','${temp.peploNo }','${temp.totalPrice }','${temp.createTime }','${temp.state }')" ><img src="${pageContext.request.contextPath }/admin/images/search.gif" alt="详细" /></a>
					</td>
	  		</tr>
		  	</s:iterator>
        </tbody>
			</table>
     </div>
     <!-- End Table Content -->
     
   </div>
   
   <!-- End Box Content -->
   
  <div class="clear"></div>
  <%-- 加载底部 --%>
  <s:include value="../main/footer.jsp"></s:include>
  </div>
  </body>
</html>
